﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace shop.Logi
{
    public partial class SyncTradeDialog : Form
    {

        shop.Bll.trade.TradeBll _bll = new shop.Bll.trade.TradeBll();

        public SyncTradeDialog()
        {
            InitializeComponent();
        }



        private async void btn_sync_Click(object sender, EventArgs e)
        {
            this.bar.Visible = true;
            this.btn_sync.Enabled = false;

            //try
            //{
                var res = await _bll.SyncTradeData(this.box_begin.Value.Date.AddHours(11),
                this.box_begin.Value.Date.AddDays(1))
                    .ConfigureAwait(false);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, Properties.Resources.systemInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);

            //    this.DoInvoke(() =>
            //    {
            //        this.bar.Visible = false;
            //        this.btn_sync.Enabled = true;

            //        this.label2.Text = "";
            //    });

            //    throw ex;
            //    //return;
            //}

            this.DoInvoke(() => {
                this.bar.Visible = false;
                this.btn_sync.Enabled = true;

                this.label2.Text = "数据同步完成";
            } );



        }
    }
}
